# -*- coding: utf-8 -*-
# @Time:  2025/7/20 17:34
# @File:  models.py
# @Action:
from datetime import datetime
from sqlmodel import SQLModel, Field, Relationship
from typing import Optional

class UserBase(SQLModel):
    username: str = Field(index=True)
    email: str = Field(index=True, unique=True)
    gender: int = Field(default=1)  # 1:男, 2:女
    age: int = Field(default=18)

class User(UserBase, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    create_time: datetime = Field(default_factory=datetime.utcnow)

class UserCreate(UserBase):
    pass

class UserRead(UserBase):
    id: int
    create_time: datetime